var app = getApp()
Page({
  data:{
    current: 0,
    cakes:[{
      name:"草莓奶油蛋糕1",
      introduce:"6寸 淡奶蛋糕 黄色 红色小猪 数字蜡烛 贺卡1",
    }],
    price:[{
      money:"2.00",
    }],
    refund:[{
      price:"160",
    }]
  },
  onPullDownRefresh: function () {
    console.log('onPullDownRefresh')
  },
  onLoad:function(options){
    var id = options.id;
    // 页面初始化 options为页面跳转所带来的参数
    var that = this;
    wx.request({
      url: 'https://www.cakeyouxuan.com/small/order/tuikuan_info',
      data: {
        id: id,
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"  //post
      },
      success: function (res) {
        console.log(res);
        that.setData({
          other: res.data.other,
          order: res.data.order,
        })
      },
    })
  },
  //详情页跳转
  lookdetail:function(e){
    var lookid=e.currentTarget.dataset;
    console.log(e.currentTarget.dataset.id);
    wx.navigateTo({
      url:"/pages/yiguo/detail/detail?id="+lookid.id
    })
  },
  switchSlider:function(e){
    this.setData({
      current:e.target.dataset.index
    })
  },
  changeSlider:function(e){
    this.setData({
      current: e.detail.current
    })
  },
  submit: function (e) {
    wx.navigateTo({
      url: "/pages/yiguo/refund-2/refund-2"
    })
  },
  
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },

  // 提交退款申请
  formSubmit:function(e){
    var id = e.detail.target.dataset.id;
    var price = e.detail.value.price;
    var shuoming = e.detail.value.shuoming;
    var yuanyin = e.detail.value.yuanyin;
    var uid = app.whereId.uid;
    wx.request({
      url: 'https://www.cakeyouxuan.com/small/order/tuikuan_tijiao',
      data: {
        id: id,
        price: price,
        shuoming: shuoming,
        yuanyin: yuanyin,
        uid:uid,
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"  //post
      },
      success: function (res) {
        if (res.data.msg == 'T'){
          wx.showToast({
            title: '申请成功',
            icon: 'success',
            duration: 2000,
            success: function () {
              wx.navigateBack({
                delta: 2
              })
            }
          })
        }
      },
    })
  },

})
